<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>导航栏</title>
    <style>
        body {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100vh;
            background-color: #e8e8e8;
        }

        .flex {
            width: 50vw;
            height: 80px;
            line-height: 80px;
            background-color: white;
            position: absolute;
            left: 50%;
            top: 50%;
            margin: -25px 0 0 -25vw;
        }

        .flex ul {
            display: flex;
            padding: 0;
            margin: 0;
            box-shadow: 0 10px 20px 0 rgba(0, 0, 0, 0.25);
        }

        .flex ul li {
            flex: 1;
            list-style: none;
            text-align: center;
            position: relative;
            font-size: 20px;
            font-weight: bold;
            transition: 0.5s ease;
            cursor: pointer;
            user-select: none;
        }


        .flex ul li:hover {
            background-color: rgba(255, 255, 255, 0.25);
            color: #f564a9;
        }

        .flex ul li:hover:nth-of-type(2) ~ .bar {
            left: 20%;
        }

        .flex ul li:hover:nth-of-type(3) ~ .bar {
            left: 40%;
        }

        .flex ul li:hover:nth-of-type(4) ~ .bar {
            left: 60%;
        }

        .flex ul li:hover:nth-of-type(5) ~ .bar {
            left: 80%;
        }

        .flex ul .bar{
            width: 20%;
            background-color: #f564a9;
            height: 5px;
            position: absolute;
            left: 0;
            bottom: 0;
            transition: 0.5s ease;
        }

    </style>
</head>
<body>
<div class="flex">
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
        <div class="bar"></div>
    </ul>
</div>
</body>
</html>
